#include "Viewport.h"
#include "Renderable2d.h"
#include "GraphicFactory.h"

namespace Graphics
{
	Renderable2D::Renderable2D(void):m_pViewport(0)
	{
	}
	Renderable2D::~Renderable2D(void)
	{
	}
	void Renderable2D::SetViewport(Viewport* viewport)
	{
		if(m_pViewport == viewport)
		{
			return;
		}
		else if(m_pViewport == 0)
		{
			GraphicFactory::getInstance()->GetGraphic2D()->Remove(this);
		}
		else
		{
			m_pViewport->Remove(this);
		}
		
		m_pViewport = viewport;

		if(m_pViewport == 0)
		{
			GraphicFactory::getInstance()->GetGraphic2D()->Add(this);
		}
		else
		{
			m_pViewport->Add(this);
		}
	}

	Viewport* Renderable2D::GetViewport(void)
	{
		return m_pViewport;
	}
}